<template>
  <el-menu
    :style="{
      width: !headData.isCollapse ? '230px' : '64px',
    }"
    style="transition: all 0.3s ease-in-out"
    default-active="1-1"
    class="aside-container"
    @open="handleOpen"
    @close="handleClose"
    background-color="#ec5e51"
    text-color="#fff"
    unique-opened="true"
    active-text-color="#3b1308"
    :collapse="headData.isCollapse"
  >
    <img v-show="!headData.isCollapse" src="../assets/logo.png" alt="" />
    <p
      :style="{
        borderRadius: headData.isCollapse ? '50%' : '0',
        backgroundColor: headData.isCollapse ? '#ffffff' : '#ec5e51',
        fontSize: headData.isCollapse ? '15px' : '24px',
        color: headData.isCollapse ? '#ec5e51' : '#ffffff',
        width: headData.isCollapse ? '50px' : '220px',
      }"
      class="logo"
    >
      <!-- <div>{{ $t("messages.loginTitle") }}</div> -->
      {{ headData.isCollapse ? "厚溥" : $t("messages.loginTitle") }}
    </p>
    <!-- 父子组件通讯 -->
    <TreeMenu :index="1" :menuData="menuData" />
  </el-menu>
</template>

<script setup>
import TreeMenu from "@/components/treeMenu.vue";
import { useRouter } from "vue-router";
import { reactive } from "vue";
import { headStore } from "@/stores/headStore.js";
const headData = headStore();
const router = useRouter();
const menuData = reactive(router.options.routes[2].children);
const handleClose = () => {
  console.log("close");
};
const handleOpen = () => {
  console.log("open");
};
</script>

<style scoped lang="less">
.aside-container {
  padding-top: 20px;
  height: 100%;
  img {
    width: 30%;
    display: block;
    margin: auto;
  }
  .logo {
    display: block;
    margin: auto;
    color: aliceblue;
    font-size: 24px;
    text-align: center;
    height: 50px;
    line-height: 50px;
    background-color: #ec5e51;
    color: #ffffff;
    font-weight: 900;
    margin-bottom: 20px;
  }
}
/deep/ .el-menu-item.is-active {
  background-color: rgba(34, 34, 34, 0.2) !important;
  color: #fbf396 !important;
  font-weight: 900 !important;
}
</style>
